<?php

/**
 * MVM_MALL 网上商店系统  会员中心
 * ============================================================================
 * 版权所有 (C) 2007-2010 www.mvmmall.com，并保留所有权利。
 * 网站地址: http://www.mvmmall.com
 * ----------------------------------------------------------------------------
 * 这是一个免费开源的软件；这意味着您可以在不用于商业目的的前提下对程序代码
 * 进行修改、使用和再发布。
 * ============================================================================
 * $Author:  www.mvmmall.com  $
 * $Date: 2008-06-12 $
 * $Id: member.php  www.mvmmall.com$
 * ---------------------------------------------
*/

require_once 'include/common.inc.php';
!$m_check_id &&  show_msg('login_please',GetBaseUrl('logging','login'));
switch ($action) {
    case 'profile'://会员资料修改
    {
    	if ($ps_mode=='modify'){
    		$list = $db->get_one("SELECT member_id,member_email,member_pass FROM `{$tablepre}member_table` WHERE `member_id` = '$m_check_id'");
    		if ($old_pass) {
    			$old_pass = md5($old_pass);
    			$old_pass != $list['member_pass'] && show_msg('password_rqual');
    			if(($pass1 && $pass2) && ($pass1 == $pass2)) {
    				$insert_pass = md5($pass1);
    			} else {
    				show_msg('password_rqual');
    			}
    		} else {
    			$insert_pass = $list['member_pass'];
    		}
    		if(!ereg("^[-a-zA-Z0-9_\.]+\@([0-9A-Za-z][0-9A-Za-z-]+\.)+[A-Za-z]{2,5}$",$email)){
    			show_msg('email_err');
    		}
    		if ($list['member_email']!=$email){
    			$rs_email = $db->get_one("SELECT member_email FROM `{$tablepre}member_table` WHERE `member_email` = '$email'");
    			$rs_email['member_email'] && show_msg('user_email');
    		}
    		$birthday = $birth_yy.sprintf("%02d",$birth_mm).sprintf("%02d",$birth_dd);
    		$rows= false;
    		$rows = array(
    		'member_pass'         => $insert_pass,
    		'member_name'         => $name,
    		'member_sex'          => $sex,
    		'member_birthday'     => $birthday,
    		'member_tel1'         => $tel1,
    		'member_tel2'         => $tel2,
    		'member_email'        => $email,
    		'member_zip'          => $zip1,
    		'province'            => $province,
    		'city'                => $city,
    		'member_address'      => $address1,
    		'member_homepage'     => $homepage,
    		'icq'                 => $icq,
    		'qq'                  => $qq,
    		'yahoo'               => $yahoo,
    		'msn'                 => $msn,
    		'taobao'              => $taobao,
    		'member_automail'     => $automail,
    		'member_introduction' => $intro,
    		'member_image'        => $member_file_text,
    		'modify_id'           => $m_check_id,
    		'modify_ip'           => $m_user_ip,
    		'modify_date'         => $m_now_time
    		);
    		$rows = dhtmlchars($rows);//数据过滤
    		$db->update("{$tablepre}member_table",$rows,"member_id = '$m_check_id'");
    		show_msg('member_modify_ok');
    		exit;
    	} 
    	
    	else {
    		$user_rt = $db->get_one("SELECT * FROM `{$tablepre}member_table` WHERE member_id = '$m_check_id'");
    		($user_rt['member_id'] != $m_check_id || !$m_check_id) && show_msg('member_login_modify');
    		$zip1     = substr($user_rt['member_zip'],0,6);
    		$jumin1   = substr($user_rt['member_jumin'],0,18);
    		$birth_yy = substr($user_rt['member_birthday'],0,4);
    		$birth_mm = substr($user_rt['member_birthday'],4,2);
    		$birth_dd = substr($user_rt['member_birthday'],6,2);
    		@extract($user_rt);
    		drop_check($member_automail,'automail');
            drop_check($member_sex,'sex');
    		require_once MVMMALL_ROOT.'header.php';
    		require_once template('member_profile');
    	}
    	
        break;
    }
    
    case 'point'://会员积分查询
    {
        if ($setp==1&&$_POST){
           $mm_barter_use==0 && show_msg('point_close'); 
          //积分换预付款
           $point_nums   = round($point_nums,0);
           $member_point = $db->get_one("SELECT member_point,member_id,member_money FROM `{$tablepre}member_table` WHERE member_id='$m_check_id'");
           ($member_point['member_point']<$point_nums ||$member_point['member_point']<$mm_point_barter) && show_msg('point_err');
           //执行转换
           $money    = @round(($point_nums/$mm_point_barter),2); //转换后的值
           $point    = ($member_point['member_point']-$point_nums);
           $up_money = ($member_point['member_money']+ $money);  
           //更新会员数据库
           $db->query("UPDATE `{$tablepre}member_table` SET member_point='$point',member_money='$up_money' WHERE member_id='$m_check_id'");
           //写入积分记录
           $query = "INSERT INTO `{$tablepre}point_table` SET
                      point_id       = '$m_check_id',
                      point_add      = '-$point_nums',
                      point_reason   = '$lang[barter_msg]',
                      point_category = '1',
                      modify_id      = '$m_check_id',
                      modify_ip      = '$m_user_ip',
                      register_date  = '$m_now_time',
                      approval_date  = '$m_now_time'";
           $db->query($query);
           //写入预付款记录
           $query = "INSERT INTO `{$tablepre}money_table` SET
                      money_id       = '$m_check_id',
                      money_add      = '$money',
                      money_reason   = '$lang[barter_msg]',
                      modify_id      = '$m_check_id',
                      modify_ip      = '$m_user_ip',
                      money_category = '0',
                      register_date  = '$m_now_time',
                      approval_date  = '$m_now_time' ";
           $db->query($query);
          //更新会员登陆的session
          $_SESSION['user']['mvm_sess_point'] = number_format($point,0);
          $_SESSION['user']['mvm_sess_money'] = $up_money;
          show_msg('barter_ok',dreferer()); 
        }  
        else {
        	$total_count = $db->counter("{$tablepre}point_table","`point_category` = '1' AND `point_id` = '$m_check_id'");
        	require_once MVMMALL_ROOT.'./include/pager.class.php';
        	$page        = $page ? (int)$page:1;
        	$list_num    = 10;
        	$rowset      = new Pager($total_count,$list_num,$page);
        	$from_record = $rowset->_offset();
        	$query = $db->query("SELECT * FROM `{$tablepre}point_table` WHERE `point_category` = '1' AND `point_id` = '$m_check_id' ORDER BY `uid` DESC LIMIT $from_record, $list_num");
        	while($rt = $db->fetch_array($query)) {
        		$rt['date']     = date($mm_date_format,$rt['register_date']);
        		$rt['point']    = number_format($rt['point_add']);
        		$rt['approval'] = $rt['approval_date'] > '10' ? $lang['approval_yes']:$lang['approval_no'];
        		++$a;
        		($a%2)==0 && $rt['css']='class="s"';
        		$point[]       = $rt;
        	}
        	$page_list  = $rowset->link('member.php?action=point&page=');
        	$navigation = make_navigation($lang['user_point'],"member.php?action=point&page=$page");//导航
        	require_once MVMMALL_ROOT.'header.php';
        	require_once template('member_point');
        }
        break;

    }
    
    case 'money'://会员预付款查询
    {
        $total_count = $db->counter("{$tablepre}money_table","money_category='0' AND money_id = '$m_check_id'");
        require_once MVMMALL_ROOT.'./include/pager.class.php';
        $page        = $page ? (int)$page:1;
        $list_num    = 10;
        $rowset      = new Pager($total_count,$list_num,$page);
        $from_record = $rowset->_offset();
        $po_result   = $db->query("SELECT * FROM `{$tablepre}money_table` WHERE money_category='0' AND money_id = '$m_check_id' ORDER BY uid DESC LIMIT $from_record, $list_num");
        while($rt = $db->fetch_array($po_result)) {
			$rt['date']     = date($mm_date_format,$rt['register_date']);
			$rt['money']    = currency($rt['money_add']);
			++$a;
			($a%2)==0 && $rt['css']='class="s"';
			$rt['approval'] = $rt['approval_date'] > '10'?$lang['approval_yes']:$lang['approval_no'];
            $money_log[]    = $rt;
        }
        //支付列表
        $payment= payment_list();
        foreach ($payment as $key=>$val){
            if ($val['class_name']=='integral') unset($payment[$key]);
            if ($val['class_name']=='advance') unset($payment[$key]);
        }
        $page_list  = $rowset->link('member.php?action=money&page=');
        $navigation = make_navigation($lang['user_money'],"member.php?action=money&page=$page");//导航
        require_once MVMMALL_ROOT.'header.php';
        require_once template('member_money');
        break;

    }
    
    //支付预付款
    case 'pay':
    {
    	if($setp==1 && $_POST){
    		$pay_id = (int)$pay_id;
    		$pay    = $db->get_one("SELECT id,class_name,name,pay_desc,cfg FROM `{$tablepre}payment_table` WHERE id='$pay_id'");
    		$pay == false && show_msg('db_avess');
    		($pay['class_name']=='advance'||$pay['class_name']=='integral') && move_page(dreferer());
    		if(file_exists(MVMMALL_ROOT.'./include/payment/'. $pay['class_name'].'.class.php')){
    			require_once MVMMALL_ROOT.'./include/payment/'. $pay['class_name'].'.class.php';
    		}else {
    			show_msg('db_avess');
    		}
    		$ordersn   = date('Ymdhis');
    		$pay_money = floatval($pay_money);
    		$rowst     = new  $pay['class_name'](unserialize($pay['cfg']));
    		$code_form = $rowst->pay_send($ordersn,$pay_money);
    		//写入预存款记录
    		$query = "INSERT INTO `{$tablepre}money_table` SET
                      money_sess     = '$ordersn',
                      money_id       = '$m_check_id',
                      money_add      = '$pay_money',
                      money_reason   = '$lang[show_money]',
                      modify_ip      = '$m_user_ip',
                      register_date  = '$m_now_time'";
    		$db->query($query);
    		//写入支付记录表
    		$db->query("INSERT INTO `{$tablepre}pay_log` (`order_sn`, `order_amount`,`order_type`, `status`) 
    		            VALUES ('$ordersn','$pay_money', '1', '0')");
    		require_once MVMMALL_ROOT.'header.php';
    		require_once template('pay_money');
    	}else {
    		show_msg('pass_worng');
    	}
    	break;
    }
    
    case 'info'://我的盈利推广
    {
    	if($setp==1){
    		//推广币
    		$mytotalinfo = false;
    		$mytotalinfo = $db->get_one("SELECT SUM(point_add) FROM `{$tablepre}point_table` WHERE `point_category` = '6' AND `point_id` = '$m_check_id'");
    		$mytotalinfo  = array_sum($mytotalinfo);
    		if($mm_extend == '1' && $mm_zhuanhua>0){
    			if($info<0){
    				show_msg('input_wrong');
    			}elseif ($info>$mytotalinfo){
    				show_msg('input_more');
    			}elseif ($info<$mm_zhuanhua){
    				show_msg('input_small');
    			}
    			$nums_info  = @ceil($info/$mm_zhuanhua); //转换后的值
    			if ($mm_monysetup=='1') {
    				$new_point_text = $lang['point_text'];
    				$query = "INSERT INTO `{$tablepre}point_table` SET
                      point_id       = '$m_check_id',
                      point_add      = '$nums_info',
                      point_reason   = '$new_point_text',
                      modify_id      = '$m_check_id',
                      modify_ip      = '$m_user_ip',
                      point_category = '1',
                      register_date  = '$m_now_time',
                      approval_date  = '$m_now_time' ";
    				$db->query($query);
    				$db->query("UPDATE `{$tablepre}member_table` SET member_point = member_point + '$nums_info' WHERE `member_id` = '$m_check_id'");
    				//更新session的积分显示
    				$_SESSION['user']['mvm_sess_point'] = ($m_check_point+$nums_info);
    			} else{
    				$new_money_text = $lang['money_text'];
    				$query = " INSERT INTO `{$tablepre}money_table` SET
                      money_id       = '$m_check_id',
                      money_add      = '$nums_info',
                      money_reason   = '$new_money_text',
                      modify_id      = '$m_check_id',
                      modify_ip      = '$m_user_ip',
                      money_category = '0',
                      register_date  = '$m_now_time',
                      approval_date  = '$m_now_time' ";
    				$db->query($query);
    				$db->query("UPDATE `{$tablepre}member_table` SET member_money = member_money + '$nums_info' WHERE `member_id` = '$m_check_id'");
    				//更新session的预存款显示
    				$_SESSION['user']['mvm_sess_money'] = ($m_check_money+$nums_info);

    			}
    			$new_point_text = "$lang[conversion] $mm_monyname $lang[exchange_nums]：$totalinfo";
    			$query = "INSERT INTO `{$tablepre}point_table` SET
                      point_id       = '$m_check_id',
                      point_add      = '-$info',
                      point_reason   = '$new_point_text',
                      point_category = '6',
                      modify_id      = '**',
                      modify_ip      = '$m_user_ip',
                      register_date  = '$m_now_time'";
    			$db->query($query);
    			show_msg('info_ok',dreferer());
    			exit;
    		} else {
    			show_msg('myinfo_error');
    		}
    	} else {
    		require_once MVMMALL_ROOT.'./include/pager.class.php';
    		$total_count   = $db->counter("{$tablepre}point_table","`point_category` = '6' AND `point_id` = '$m_check_id'", "*");
    		$page          = $page ? (int)$page:1;
    		$list_num      = 10;
    		$rowset        = new Pager($total_count,$list_num,$page);
    		$from_record   = $rowset->_offset();
    		$result        = $db->query("SELECT * FROM `{$tablepre}point_table` WHERE `point_category` = '6' AND `point_id` = '$m_check_id' ORDER BY `uid` DESC LIMIT $from_record, $list_num");
    		while($rt = $db->fetch_array($result)) {
    			$rt['date']    = date($mm_date_format,$rt['register_date']);
    			++$a;
    			($a%2)==0 && $rt['css']='class="s"';
    			$member_info[] = $rt;
    		}
    		//推广图片
    		foreach ($cache->get_cache('info') as $val){
    			$val['img']  = MVMMALL_DIR."/$val[img]";
    			$val['link'] = strstr($val['link'], '?')?"$val[link]&userid=$m_check_uid":"$val[link]?userid=$m_check_uid";
    			$info_rt[]   = $val;
    		}
    		//推广币
    		$totalinfo  = $db->get_one("SELECT SUM(point_add) FROM `{$tablepre}point_table` WHERE `point_category` = '6' AND `point_id` = '$m_check_id'");
    		$totalinfo  = array_sum($totalinfo);
    		$page_list  = $rowset->link('member.php?action=info&page=');
    		$link_url   = MVMMALL_DIR."/?userid=$m_check_uid";
    		$navigation = make_navigation($lang['navi_info'],"member.php?action=info&page=$page");//导航
    		require_once MVMMALL_ROOT.'header.php';
    		require_once template('member_info');
    	}
    	break;
    }
    
    case 'auction'://我的拍卖记录
    {
        require_once MVMMALL_ROOT.'./include/pager.class.php';
        $total_count = $db->counter("{$tablepre}auction_table","WHERE userid='$m_check_id'");
        $page        = $page ? (int)$page:1;
        $list_num    = 10;
        $rowset      = new Pager($total_count,$list_num,$page);
        $from_record = $rowset->_offset();
        $sql="SELECT a.*,b.goods_id,b.end_time,c.goods_name,c.uid FROM `{$tablepre}auction_table` a INNER JOIN `{$tablepre}activity`  b ON a.act_id=b.act_id INNER JOIN `{$tablepre}goods_table` c ON b.goods_id=c.uid WHERE a.userid='$m_check_id' ORDER BY a.regdate DESC LIMIT $from_record, $list_num";
        $result = $db->query($sql);
        while($rt = $db->fetch_array($result)) {
        	$rt['url']      = "auction.php?action=view&id=$rt[act_id]";
        	$rt['end_time'] = date($mm_date_format,$rt['end_time']);
        	$rt['title']    = $rt['goods_name'];
            $myresult       = $db->query("SELECT  MAX(price)  FROM {$tablepre}auction_table WHERE act_id='$rt[act_id]'");
            $maxprice       = $db->fetch_array($myresult);
            if($rt['price']<$maxprice['0']){
                $rt['approval']= $lang['outgoing'];
            }elseif($rt['price']>=$maxprice['0'] && $rt['end_date']<$m_now_time) {
               $rt['approval']="$lang[saleok]".'<IMG src='.$imgpath.'/okhank.gif>';
            }else {
                $rt['approval'] = $lang['ontop'].'<IMG src='.$imgpath.'/okhank.gif>';
            }
             ++$a;
            ($a%2)==0 && $rt['css']='class="s"';
             $auction[] = $rt;
        }
        $page_list   = $rowset->link('member.php?action=auction&page=');
        $navigation  = make_navigation($lang['my_auction'],"member.php?action=auction&page=$page");//导航
        require_once MVMMALL_ROOT.'header.php';
        require_once template('member_auction');
        break;
    }
    case 'order'://我的定单
    {
        require_once MVMMALL_ROOT.'./include/pager.class.php';
        $total_count = $db->counter("{$tablepre}order_info","username='$m_check_id'");
        $page        = $page ? (int)$page:1;
        $list_num    = 10;
        $rowset      = new Pager($total_count,$list_num,$page);
        $from_record = $rowset->_offset();
        $result      = $db->query("SELECT * FROM `{$tablepre}order_info` WHERE username='$m_check_id' ORDER BY uid DESC LIMIT $from_record, $list_num");
        $order_list  = array();
        while ($rt = $db->fetch_array($result)){
            ++$a;
            ($a%2)==0 && $rt['css']='class="s"';
            //取消定单
            if ($rt['status']==1){
               $rt['admin']="<a href='javascript:;' onclick=\"chang_order($rt[uid])\"><span id=\"a$rt[uid]\">$m_order_array[8]</span></a>";
            }elseif ($rt['status']==8){
               $rt['admin']="<a href='javascript:;' onclick=\"chang_order($rt[uid])\"  /><span id=\"a$rt[uid]\">$lang[resume_order]</span></a>";
            }else {
                $rt['admin']='--';
            }
            $rt['status']  = "<span id=\"s$rt[uid]\">".$m_order_array[$rt['status']]."</span>";
            $rt['addtime'] = date($mm_date_format,$rt['addtime']);
            $order_list[]  = $rt;
        }
        $page_list   = $rowset->link('member.php?action=order&page=');
        $navigation  = make_navigation($lang['my_order'],"member.php?action=order&page=$page");//导航
        require_once MVMMALL_ROOT.'header.php';
        require_once template('member_order');
        break;
    }
    
    //改变定单状态
    case 'chang_order':
    {
    	!is_numeric($uid) && show_msg('pass_worng');
    	$order_list = $db->get_one("SELECT ordersn,status,uid,username FROM `{$tablepre}order_info` WHERE uid = '$uid' and username='$m_check_id'");
    	$order_list ==false && exit($lang['db_avess']);
    	if ($order_list['status']==1){
    		$db->query("UPDATE `{$tablepre}order_info` SET status='8' WHERE username='$m_check_id' AND uid='$uid'");//取消定单
    		$arr['status'] = $m_order_array[8];
    		$arr['admin']  = $lang['resume_order'];
    		$arr['err']    = 0;
    	}elseif ($order_list['status']==8){
    		$db->query("UPDATE `{$tablepre}order_info` SET status='1' WHERE username='$m_check_id' AND uid='$uid'");//恢复定单
    		$arr['status'] = $m_order_array[1];
    		$arr['admin']  = $m_order_array[8];
    		$arr['err']    = 0;
    	}else {
    		$arr['err']  = $lang['chang_order_err'];
    	}
    	$arr['uid'] = $uid;
    	require_once MVMMALL_ROOT.'./include/json.class.php';
    	$json = new Services_JSON;
    	echo $json->encode($arr);
    	exit;
    }
    //修改定单
    case 'edit_order':
    {
        if ($setp==1&&$_POST){
            $order_row  = dhtmlchars($order_row);
            $uid        = (int)$uid;
            $order_info = $db->get_one("SELECT ordersn,status,uid,username,goods_amount,sh_exes,cas_exes FROM `{$tablepre}order_info` WHERE uid = '$uid' and username='$m_check_id'");
            $order_info == false && show_msg('db_avess');
            ($order_info['status']!='1'&& $order_info['status']!='8' ) && show_msg('chang_order_err');  //定单处于不可操作状态
            $pay_id     = (int)$pay_id;
            $pay = $db->get_one("SELECT * FROM `{$tablepre}payment_table` WHERE id='$pay_id'");
            if ($pay['name']){
                $order_row['pay_name'] = $pay['name'];
                $order_row['pay_id']   = $pay_id;
            }else {
                show_msg('db_avess');
            }
            //包装费用
            //包装费用
            $casing_id             = (int)$casing_id;
            $pack_rt               = $db->get_one("SELECT fee,price,id,name FROM `{$tablepre}pack` WHERE id='$casing_id'");
            $pack_rt['price']      = ($rowset->total_price>=$pack_rt['fee'] && $pack_rt['fee']>0)? 0.00 : $pack_rt['price'];
            $order_row['cas_name'] = $pack_rt['name'];
            $order_row['cas_exes'] = $pack_rt['price'];
            //定单总额
            $order_row['order_amount'] = ($order_row['cas_exes']+$order_info['goods_amount']+$order_info['sh_exes']);
            $order_row['invoice'] && $order_row['order_amount'] +=($order_row['order_amount']*$mm_cess);
            $db->update("{$tablepre}order_info",$order_row,"uid = '$uid' AND username='$m_check_id'");
            show_msg('edit_success',dreferer());
            exit;
        }
         
        else {
        	$ps_id = (int)$ps_id;
        	$order_info = $db->get_one("SELECT * FROM `{$tablepre}order_info` WHERE uid = '$ps_id' and username='$m_check_id'");
        	$order_info == false ? show_msg('db_avess') : $rt_goods = order_goods($ps_id) ;$cart_goods=$rt_goods['goods'];
        	//生成支付代码
        	$pay_id = (int)$order_info['pay_id'];
        	$pay    = $db->get_one("SELECT * FROM `{$tablepre}payment_table` WHERE id='$pay_id'");
        	if(file_exists(MVMMALL_ROOT.'./include/payment/'. $pay['class_name'].'.class.php')){
        		include MVMMALL_ROOT.'include/payment/'. $pay['class_name'].'.class.php';
        		$rowst     = new  $pay['class_name'](unserialize($pay['cfg']));
        		$code_form = $rowst->pay_send($order_info['ordersn'],$order_info['order_amount']);
        	}else {
        		show_msg('db_avess');
        	}
        	//end
        	
        	//包装方式
        	$wrapping = $cache->get_cache('pack');

        	//取消定单连接
        	if ($order_info['status']==1){
        		$order_info['admin']="<input
               OnClick=\"window.location='member.php?action=chang_order&uid=$order_info[uid]'\" 
               class=btn2 type=button value=$m_order_array[8] /></a>";
        	}elseif ($order_info['status']==8){
        		$order_info['admin']="<input
               OnClick=\"window.location='member.php?action=chang_order&uid=$order_info[uid]'\" 
               class=btn2 type=button value=$lang[resume_order] /></a>";
        	}else {
        		$order_info['admin']='';
        		$order_info['disabled']='disabled';
        	}
        	//end
        	
        	$order_info['invoice'] && $cess_price = currency(floatval($order_info['goods_amount']*$mm_cess)); //发票
        	$total_price                 = currency($total_price);
        	$order_info['sh_exes']       = currency($order_info['sh_exes']);
        	$order_info['cas_exes']      = currency($order_info['cas_exes']);
        	$order_info['goods_amount']  = currency($order_info['goods_amount']);
        	$order_info['order_amount']  = currency($order_info['order_amount']);
        	$order_info['status']        = $m_order_array[$order_info['status']];
        	$navigation                  = make_navigation($lang['buy_payorder']);//导航
        	$pay_select                  = pay_select('pay_id',$order_info['pay_id']);//支付列表
        	require_once MVMMALL_ROOT.'header.php';
        	require_once template('order_edit');
        }
        break;
    }
    
    //我的评论
    case 'comment':
    {
        require_once MVMMALL_ROOT.'./include/pager.class.php';
        $total_count = $db->counter("{$tablepre}gcomment_table","comment_name='$m_check_id' AND approval_date>'0'");
        $page        = $page ? (int)$page:1;
        $list_num    = 10;
        $rowset      = new Pager($total_count,$list_num,$page);
        $from_record = $rowset->_offset();
        $result = $db->query("SELECT a.*,b.goods_name,b.uid AS goods_id FROM  `{$tablepre}gcomment_table` a LEFT JOIN `{$tablepre}goods_table` b ON a.guid=b.uid WHERE a.comment_name='$m_check_id' AND a.approval_date>'0' ORDER BY a.approval_date DESC LIMIT $from_record, $list_num");
        unset($comment);
        while ($rt = $db->fetch_array($result)){
            $rt['title']           = dhtmlchars($rt['comment_subject']);
            $rt['conter']          = dhtmlchars($rt['comment_body']);
            $rt['name']            = dhtmlchars($rt['comment_name']);
            $rt['date']            = date($mm_date_format, $rt['register_date']);
            $rt['url']             =  GetBaseUrl('product',$rt['guid']);
            $rt['reply']           = $rt['comment_main'];
            $rt['star']            = "<IMG  src='$imgpath/Egg_$rt[comment_star].gif'>";
            $rt['approval_date']   = $rt['approval_date']>1 ? date($mm_date_format,$rt['approval_date']):'';
            $rt['comment_id']      = $m_class_array[$rt['comment_id']];
            $result = $db->query("SELECT * FROM  `{$tablepre}reply_comment` WHERE com_id='$rt[uid]' ORDER BY reply_id DESC");
            while ($rep = $db->fetch_array($result)) {
            	$rep['reply_date'] = date($mm_date_format, $rep['reply_date']);
            	$rep['user_id']    = $m_class_array[$rep['user_id']];
            	$reply[]           = $rep;
            }
            $rt['reply'] = $reply;
            $comment[]      = $rt;
            unset($reply);
        }
        $page_list   = $rowset->link('member.php?action=comment&page=');
        $navigation  = make_navigation($lang['my_comment'],"member.php?action=comment&page=$page");//导航
        require_once MVMMALL_ROOT.'header.php';
        require_once template('comment');
        break;
    }
        
    //收货地址
    case 'address':
    {
    	if ($setp==1&&$_POST){
    		$address_row = array(
    		'add_name'  => $add_name,
    		'is_buy'    => $is_buy,
    		'consignee' => $consignee,
    		'tel'       => $tel,
    		'mobile'    => $mobile,
    		'email'     => $email,
    		'province'  => $province,
    		'city'      => $city,
    		'address'   => $address,
    		'zipcode'   => $zipcode,
    		);
    		$address_row['member_id']=$m_check_uid;
    		if ($act=='edit' && is_numeric($add_id)){
    			$add_info[is_buy]=='' &&  $add_info['is_buy']=0;
    			$db->update("{$tablepre}address",dhtmlchars($address_row),"member_id='$m_check_uid' AND id='$add_id'");
    		}else {
    			$address_nums = $db->counter("{$tablepre}address","member_id='$m_check_uid'");//判断收货地址个数
    			$address_nums>=3 && show_msg('nums_address');
    			$db->insert("{$tablepre}address",dhtmlchars($address_row));
    		}
    		move_page('member.php?action=address');
    		exit;
    	}

    	else {
    		if ($act=='edit' && is_numeric($add_id)){
    			$add_info=$db->get_one("SELECT * FROM `{$tablepre}address` WHERE member_id='$m_check_uid'AND id='$add_id'");
    			$add_info==false && show_msg('db_avess');
    			$add_info['is_buy'] = $add_info['is_buy']==1 ?'checked':'';
    		}
    		unset($member_address);
    		$result    = $db->query("SELECT * FROM `{$tablepre}address` WHERE member_id='$m_check_uid'");
    		while ($rt = $db->fetch_array($result)){
    			$member_address[] = $rt;
    		}
    		$navigation  = make_navigation($lang['buyer_add'],'member.php?action=address');//导航
    		require_once MVMMALL_ROOT.'header.php';
    		require_once template('member_address');
    	}
    	break;
    }
    
    //删除地址
    case 'deladdress':
    {
        is_numeric($add_id) && $db->query("DELETE FROM `{$tablepre}address` WHERE member_id='$m_check_uid' AND id='$add_id'");
        move_page(dreferer());
        break; 
    }
    //会员中心
    default:
    {
    	break;
    }
}
footer();
